package cn.itsource.pethome.Basic.util;

import cn.itsource.pethome.user.domain.User;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;

public class UserContext {
    public static User getLoginUser(HttpServletRequest request){
        //获取用户token值
        String token = request.getHeader("U-TOKEN");
        //获取用户json字符串
        String jsonUser = RedisUtils.INSTANCE.get(token);
        //将用户json字符串转换为json对象
        User user = JSONObject.parseObject(jsonUser, User.class);
        return user;

    }
}
